package com.zh.authserver.config;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import java.io.IOException;

/**
 * @author Zhou
 * @date 18:13 2025/10/13
 */
@Slf4j
public class IPWhitelistFilter extends OncePerRequestFilter {

    public IPWhitelistFilter(String tag) {
        log.info("[IPWhitelistFilter] constructor... "+tag);
    }

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        log.info("do IpWhitelist filter ...  uri = {} \t remoteHost = {}, remoteAddr = {} ", request.getRequestURI(), request.getRemoteHost(), request.getRemoteAddr());
        filterChain.doFilter(request, response);
    }
}
